#include "stdio.h"
#include "cc.h"
#include "bsp_clk.h"
#include "bsp_delay.h"
#include "bsp_led.h"
#include "bsp_uart.h"
#include "bsp_beep.h"
#include "bsp_key.h"

int main(int argc, const char * argv[])
{
	int i = 0;
	int keyvalue = 0;
	unsigned char led_state = OFF;
	unsigned char beep_state = OFF;
	
	clk_enable(); /* 使能所有的时钟 */
	uart_init();  /* 初始化串口，波特率115200 */
	led_init();	  /* 初始化led  */
	beep_init();  /* 初始化beep */
	key_init();	  /* 初始化key  */

	while (1)
	{
		keyvalue = key_getvalue();
		if(keyvalue)
		{
			switch ((keyvalue))
			{
				case KEY0_VALUE:
					beep_state = !beep_state;
					beep_switch(beep_state);
					break;
			}
		}

		i++;
		if(i==50)
		{
			i = 0;
			led_state = !led_state;
			led_switch(LED0, led_state);
		}
		delay(10);
	}

	return 0;
}

